{template 'member', 'header'}

<div class="realwrap main">
	<div class="tools clear" style="height:auto;padding:10px;">
		<form name="searchform" action="" method="get">
		<input type="hidden" value="member" name="m">
		<input type="hidden" value="shop" name="c">
		<input type="hidden" value="init" name="a">
		<table width="100%" cellspacing="0" class="">
			<tbody>
				<tr>
				<td>
				<div class="explain-col">		
					姓名：<input name="name" type="text" value="{safe_replace($_GET[name])}" style="width:80px" class="input-text">
					手机：<input name="mobile" type="text" value="{safe_replace($_GET[mobile])}" style="width:80px" class="input-text">
					商品名：<input name="goodname" type="text" value="{safe_replace($_GET[goodname])}" style="width:100px" class="input-text">
					商品类型：<select name="goodtype"><option value="" selected="">全部</option>
						<option value="day">全日房</option>
						<option value="time">小时房</option>
						<option value="goods">商品</option>
						</select>				
					订单状态：<select name="order_status">
							<option value="" selected="">全部</option>
							<option value="0">进行中</option>
							<option value="1">已完成</option>
							<option value="-1">已取消</option>
						</select>
					预约时间：<input name="timeshop" id="timeshop" type="text" value="{$_GET[timeshop]}" style="width:100px"  class="date input-text" readonly>
						<link rel="stylesheet" type="text/css" href="{JS_PATH}calendar/jscal2.css">
						<link rel="stylesheet" type="text/css" href="{JS_PATH}calendar/border-radius.css">
						<link rel="stylesheet" type="text/css" href="{JS_PATH}calendar/win2k.css">
						<script type="text/javascript" src="{JS_PATH}calendar/calendar.js"></script>
						<script type="text/javascript" src="{JS_PATH}calendar/lang/en.js"></script>
								<script type="text/javascript">
									Calendar.setup({
										weekNumbers: true,
										inputField : "timeshop",
										trigger    : "timeshop",
										dateFormat: "%Y-%m-%d",
										showTime: true,
										minuteStep: 1,
										onSelect   : function() {this.hide();}
									});
								</script>
						<input type="submit" name="search" class="button" value="搜索">
						<a href="{APP_PATH}index.php?m=member&c=shop&a=init" class="button">重置</a>
			</div>
				</td>
				</tr>
			</tbody>
		</table>
		</form>
	</div>
	
<script type="text/javascript">
var serverTime = {SYS_TIME} * 1000;
$(function(){
    var dateTime = new Date();
    var difference = dateTime.getTime() - serverTime;
	
    setInterval(function(){
      $(".endtime").each(function(){
        var obj = $(this);
        var endTime = new Date(parseInt(obj.attr('value')) * 1000);
        var nowTime = new Date();
        var nMS=endTime.getTime() - nowTime.getTime() + difference;
        var myD=Math.floor(nMS/(1000 * 60 * 60 * 24));
        var myH=Math.floor(nMS/(1000*60*60)) % 24;
        var myM=Math.floor(nMS/(1000*60)) % 60;
        var myS=Math.floor(nMS/1000) % 60;
        var myMS=Math.floor(nMS/100) % 10;
        if(myD>= 0){
			var str = myH+"小时"+myM+"分"+myS+"."+myMS+"秒";//myD+"天"+
        }else{
			var str = "已结束！";	
		}
		obj.html(str);
      });
    }, 100);
});
</script>
	<div class="table-list" style="margin:5px auto;">
		<table width="100%" style="border:1px solid #e2e2e2;">
			<thead>
				<tr>
				<th>订单号</th>
				<th>顾客姓名</th>
				<th>手机</th>
				<th>商品类型</th>
				<th>产品信息</th>
				<th>预订时间</th>
				<th>订单金额</th>
				<th>订单状态</th>
				<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<tr>   
				  {loop $listdata $val}
					<td align="center">{$val[order_id]}</td>
					<?
						$member_db = pc_base::load_model('member_model');
						$guke = $member_db->query("SELECT * FROM phpcms_member a,phpcms_member_detail b WHERE a.userid=b.userid and a.userid=".$val[user_id]);   //地区
						$guke  =mysql_fetch_assoc($guke);
						$goods = string2array($val[goods]);
					?>
					<td align="center">{$guke[name]}</td>
					<td align="center">{$guke[mobile]}</td>
					<td align="center">{if $goods[$val[frist_good]][goodtype]=='time'}小时房{elseif $goods[$val[frist_good]][goodtype]=='day'}全日房{else}商品{/if}</td>
					<td align="center">
					{loop $goods $r}
						<p>名称:{$r[title]} 数量: {$r[num]} 单价: {$r[price]}元</p>
					{/loop}
					</td>
					<td align="center">{date('Y-m-d H:i:s',$val[timeshop])}</td>
					<td align="center">{$val[price]}元</td>
					<td align="center">{if $val[order_status]==0}预订中{elseif $val[order_status]==1}预订完成{elseif $val[order_status]==-2}商家取消{elseif $val[order_status]==2}
						预约到店到计时
						 <div class="endtime" value="{php echo ($val[timeshop]+1800)}"></div>
					{else}客户退订{/if}</td>
					<td align="center">{if $val[order_status]==2 || $val[order_status]==0}<a href="{APP_PATH}index.php?m=member&c=shop&a=cancel_order&id={$val['order_id']}">取消</a>{/if}</td>
				</tr>
				{/loop}
			{/pc}
			</tbody>
		 </table>
		<div id="pages" class="text-c">{$pages}</div>
	</div>
</div>


{template 'member', 'footer'}